package com.lagou.controller;

import com.lagou.dao.EmployeeDao;
import com.lagou.domain.Dept;
import com.lagou.domain.Employee;
import com.lagou.service.DeptService;
import com.lagou.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/emp")
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;

    //查询员工
    @RequestMapping("/findAll")
    public String findAll(Model model) {
        List<Employee> employees = employeeService.findAll();
        System.out.println(employees);
        model.addAttribute("employees", employees);
        return "employee";
    }
    //添加员工
   @RequestMapping("/save")
    public String save(Employee employee){
       employeeService.save(employee);
       return "redirect:/emp/findAll";
   }
}
